﻿CREATE proc [dbo].[thuan_qtsuamenu]        
@TenMenu as nvarchar(255),          
@TenModule as nvarchar(255),          
@TenForm as nvarchar(255),          
@DienGiai as nvarchar(255),          
@Hinh as image =null,          
@MaLoaiMenu as int   ,      
@TenThuMuc as nvarchar(50)   ,  
@MenuID as int   ,  
@DuongDan as nvarchar(1000)  
 as         
declare @dem as int         
select @dem=COUNT(*) from DanhMuc_Menu where MenuID<>@MenuID   and TenForm =@TenForm and TenModule=@TenModule and TenThuMuc=@TenThuMuc      
if(@dem =0)        
begin        
        
        
         
if(@DuongDan ='' or @DuongDan is null)        
begin        
update DanhMuc_Menu set  
TenMenu =@TenMenu,          
TenModule=@TenModule,          
TenForm =@TenForm,          
DienGiai =@DienGiai,                 
MaLoaiMenu    =@MaLoaiMenu,      
TenThuMuc  =@TenThuMuc
 Where MenuID=@MenuID      
end        
        
else        
begin        
update DanhMuc_Menu set  
TenMenu =@TenMenu,          
TenModule=@TenModule,          
TenForm =@TenForm,          
DienGiai =@DienGiai,                 
MaLoaiMenu    =@MaLoaiMenu,      
TenThuMuc  =@TenThuMuc,  
Hinh=@Hinh  
 Where MenuID=@MenuID        
end        
        
        
        
select ErrCode=1        
end        
else        
begin        
select ErrCode=0        
end         
    